/*
 * @lc app=leetcode.cn id=100 lang=c
 * @lcpr version=30204
 *
 * [100] 相同的树
 */

// @lcpr-template-start

#include <stdbool.h>
#include <stdio.h>

// @lcpr-template-end
// @lc code=start
/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */
/*
struct TreeNode
{
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
};
*/
// 把这两棵树遍历一下就行,深度优先，左右左

void IsSameTree(struct TreeNode *p, struct TreeNode *q, bool *ret)
{
    if (p != NULL && q != NULL)
    {
        IsSameTree(p->left, q->left, ret);
        IsSameTree(p->right, q->right, ret);
        if (p->val != q->val)
            *ret = false;
    }
    else if (p==NULL && q==NULL)
    {
        return;
    }
    else
    {
        *ret = false;
        return;
    }
}

bool isSameTree(struct TreeNode *p, struct TreeNode *q)
{
    bool ret = true;
    IsSameTree(p, q, &ret);
    return ret;
}
// @lc code=end

/*
// @lcpr case=start
// [1,2,3]\n[1,2,3]\n
// @lcpr case=end

// @lcpr case=start
// [1,2]\n[1,null,2]\n
// @lcpr case=end

// @lcpr case=start
// [1,2,1]\n[1,1,2]\n
// @lcpr case=end

 */
